package com.yuexun.beilunpatient.ui.contractmanage.presenter.impl;

import com.yuexun.beilunpatient.base.BaseEntity;
import com.yuexun.beilunpatient.ui.contractmanage.bean.BaseBean;
import com.yuexun.beilunpatient.ui.contractmanage.bean.DiagnoseHistoryData;
import com.yuexun.beilunpatient.ui.contractmanage.model.IContractManageModel;
import com.yuexun.beilunpatient.ui.contractmanage.presenter.IDiagnoseRecordPresenter;
import com.yuexun.beilunpatient.ui.contractmanage.ui.view.IDiagnoseRecordView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by chenss on 2018/11/30.
 */
public class DiagnoseRecordPresenter implements IDiagnoseRecordPresenter {

    private IDiagnoseRecordView view;
    private IContractManageModel model;

    public DiagnoseRecordPresenter(IDiagnoseRecordView view, IContractManageModel model) {
        this.view = view;
        this.model = model;
    }

    @Override
    public void inquirePatientDiagnoseHistory(Map<String, String> praise) {
        model.inquirePatientDiagnoseHistory(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity<BaseBean<DiagnoseHistoryData>>>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("获取患者门诊就诊记录失败");
                    }

                    @Override
                    public void onNext(BaseEntity<BaseBean<DiagnoseHistoryData>> bean) {
                        view.getPatientDiagnoseHistory(bean);
                    }
                });
    }
}
